<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templates/tmpl_admin.xhtml">
	<ui:define name="centro">

		<h:form id="form1">
			<p:dataTable id="listaAcao" var="acao" value="#{acaoMBean.itens}" paginator="true" rows="10"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15" emptyMessage="Nenhum acao cadastrado" filteredValue="#{acaoMBean.itensFiltro}"
				resizableColumns="true" selectionMode="single" rowKey="#{acao.id}" selection="#{acaoMBean.acao}">

				<p:ajax event="rowSelect" update=":form2:formulario" oncomplete="acaoDialog.show()" listener="#{acaoMBean.editar}" />

				<f:facet name="header">
					Lista de Ações
				</f:facet>

				<p:column headerText="Código">
					<p:outputLabel value="#{acao.id}" />
				</p:column>

				<p:column headerText="Titulo" sortBy="#{acao.titulo}" filterBy="#{acao.titulo}" filterMatchMode="contains">
					<p:outputLabel value="#{acao.titulo}" />
				</p:column>

				<p:column headerText="Scrums p/ Compra">
					<p:outputLabel value="#{acao.scrumsCompra}" />
				</p:column>

				<p:column headerText="Ganho de Enegeria">
					<p:outputLabel value="#{acao.ganhoEnergia}" />
				</p:column>

				<p:column headerText="Ganho de Experiência">
					<p:outputLabel value="#{acao.ganhoExperiencia}" />
				</p:column>

				<p:column headerText="Tipo">
					<p:outputLabel value="#{acao.tipo}" />
				</p:column>

				<f:facet name="footer">
					<p:commandButton value="Novo" icon="ui-icon-plus" update=":form2:formulario" actionListener="#{acaoMBean.novo}"
						oncomplete="acaoDialog.show()" />
				</f:facet>
			</p:dataTable>
		</h:form>
		<h:form id="form2">
			<p:dialog header="Acao" widgetVar="acaoDialog" resizable="false" showEffect="clip" hideEffect="fold">
				<h:panelGrid id="formulario" columns="2" cellpadding="4">

					<p:outputLabel value="Título" />
					<p:inputText value="#{acaoMBean.acao.titulo}" />

					<p:outputLabel value="Scrum p/ Compra" />
					<p:inputText value="#{acaoMBean.acao.scrumsCompra}" />

					<p:outputLabel value="Ganho Energia" />
					<p:inputText value="#{acaoMBean.acao.ganhoEnergia}" />

					<p:outputLabel value="Ganho Experiência" />
					<p:inputText value="#{acaoMBean.acao.ganhoExperiencia}" />

					<p:outputLabel value="Tipo" />
					<p:selectOneMenu value="#{acaoMBean.acao.tipo}">
						<f:selectItem itemLabel="Selecione um item..." itemValue="" />
						<f:selectItem itemLabel="Lazer" itemValue="Lazer" />
						<f:selectItem itemLabel="Treinamento" itemValue="Treinamento" />
					</p:selectOneMenu>

					<p:outputLabel value="Foto:" />
					<p:fileUpload fileUploadListener="#{acaoMBean.upload}" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />

					<p:commandButton action="#{acaoMBean.salvar}" value="Salvar" update=":form1:listaAcao"
						oncomplete="acaoDialog.hide()" />
					<p:commandButton action="#{acaoMBean.deletar}" value="Deletar" rendered="#{acaoMBean.acao == 'editar'}"
						update=":form1:listaAcao" oncomplete="acaoDialog.hide()" />

				</h:panelGrid>
			</p:dialog>

		</h:form>

	</ui:define>
</ui:composition>

</html>
